package org.kotboot.enums;

import org.kotboot.kit.K;

/**
 * jisong.sun 2017/9/15 16:06
 */
public enum  BoolState implements CodeEnum<BoolState> {
    YES(1,"是"),
    NO(0,"否");

    private int code;
    private String title;

    BoolState(int code,String title){
        this.code = code;
        this.title = title;
    }

    @Override
    public int code() {
        return code;
    }

    public static BoolState of(String val){
        if(K.isEmpty(val)) return null;
        for (BoolState bs : BoolState.values()){
            if(bs.title.equals(val))
                return bs;
        }
        return null;
    }

    @Override
    public String toString() {
        return title;
    }
}
